package com.zzty.txj1.controller;

import com.zzty.txj1.entity.User;
import org.apache.catalina.servlet4preview.http.HttpServletRequest;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.Map;

@RestController
@RequestMapping("/session")
public class SessionController {

    private static final org.slf4j.Logger logger = LoggerFactory.getLogger(SessionController.class);

    @RequestMapping("/getSession")
    public Map getSession(HttpServletRequest request) {
        Map<String, Object> map = new HashMap<>();
        User user = (User) request.getSession().getAttribute("user");
        System.out.println("user: " + user.toString());
        logger.info("user: " + user);
        map.put("user", user);
        return map;
    }

}
